/*********************************************************************************
  *Copyright(C),1996-2022,ChenJiehong
  *FileName:  swtimer_config.h
  *Author:  ChenJiehong
  *Version:  V1.0
  *Date: 2023-04-18
**********************************************************************************/

#ifndef  __SWTIMER_CONF_H__
#define  __SWTIMER_CONF_H__

/***************************************Includes***********************************/
#include "stdint.h"
#include "nsuc16xx_conf.h"

/***************************************Macros***********************************/

#define SYSTICK_1MS     						(SYSCLK_FREQ_32MHz/1000)
#define C_PERIODIC_RATE 						(1U)  /*1ms*/

#define PI_TICKS_PER_MILLISECOND 		(1U)	

#define C_PI_TICKS_1MS              ( 1U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_2MS              ( 2U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_3MS              ( 3U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_5MS              ( 5U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_10MS             ( 10U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_20MS             ( 20U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_50MS             ( 50U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_80MS             ( 80U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_100MS            (100U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_125MS            (125U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_250MS            (250U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_500MS            (500U * PI_TICKS_PER_MILLISECOND)

#define C_PI_TICKS_1S              (1000U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_2S              (2000U * PI_TICKS_PER_MILLISECOND)
#define C_PI_TICKS_3S              (3000U * PI_TICKS_PER_MILLISECOND)

/***************************************Variables***********************************/
typedef enum
{
    SWTIMER_MOTOR_STOP_DELAY,				/**< Delay between drive stage from LS to TRI-STATE */
	SWTIMER_MOTOR_CTRL_PERIOD,				/**< A timer for the PID loop */
    SWTIMER_LIN_HANDLE_PERIOD,				/**< A timer for the LIN diagnostic response timeout */
	SWTIMER_1MS_TIMER,								/**< 1ms period */
	SWTIMER_MOTOR_STALL_TIME,				/**< Motor stall timer */
	SWTIMER_MOTOR_CALIBRATION_TIME,			/**< Calibration stall timer */
    SWTIMER_PROTECTION_DELAY_VSM,			/**< delay for VSM voltage protection detection */
    SWTIMER_PROTECTION_DELAY_OVT,			/**< delay for temperature protection detection */
    SWTIMER_LIN_N_AS_DELAY,
    SWTIMER_LIN_TIMEOUT,
    SWTIMER_NR_OF
} swtimer_id_t;



/***************************************Functions***********************************/



#endif
/* [] END OF swtimer_config.h */
